var Check = {

	// 用户名验证
	users : function(){

		var usersText = document.getElementsByClassName('usersText')[0],
		    users     = document.getElementsByClassName('users')[0],
		    innerText1 = '用户名不合法，请检查！',
		    innerText2 = '恭喜您，用户名合法。',
		    usersReg  = /^[a-zA-Z][a-zA-Z0-9_]{4,15}$/;

		// users 失去焦点时执行

		this.styPe({'value':users.value, 'regar':usersReg, 'Text':usersText, 'innerText1':innerText1, 'innerText2':innerText2});
	},

	// 密码验证
	pass : function(){

		var passText = document.getElementsByClassName('pass1Text')[0],
		    pass     = document.getElementsByClassName('pass1')[0],
		    innerText1 = '密码不合法，请检查！',
		    innerText2 = '恭喜您，密码合法。',
		    passReg  = /^[a-zA-Z]\w{5,17}$/;

		this.styPe({'value':pass.value, 'regar':passReg, 'Text':passText, 'innerText1':innerText1, 'innerText2':innerText2});
	},

	// 确认密码验证
	passCon : function(){

		var passText = document.getElementsByClassName('pass2Text')[0],
			pass1    = document.getElementsByClassName('pass1')[0],
		    pass2    = document.getElementsByClassName('pass2')[0],
		    innerText1 = '密码不一致，请检查！',
		    innerText2 = '密码一致。';

		this.pass();
		this.styPe({'value1':pass1.value, 'value2':pass2.value, 'Text':passText, 'innerText1':innerText1, 'innerText2':innerText2});
	},

	// Email 邮箱验证
	email : function(){

		var emailText = document.getElementsByClassName('emailText')[0],
			email    = document.getElementsByClassName('email')[0],
			emailReg  = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
		    innerText1 = 'Email格式不合法，请检查！',
		    innerText2 = 'Email合法';

		this.styPe({'value':email.value, 'regar':emailReg, 'Text':emailText, 'innerText1':innerText1, 'innerText2':innerText2});
	},

	// 公共方法
	styPe : function(obj){

		if(obj.regar != undefined ? obj.value == '' || !obj.regar.test(obj.value) : obj.value1 != obj.value2 || obj.value2 == ''){

			obj.Text.innerHTML = obj.innerText1;
			obj.Text.style.color = "#f00";
			return false;
		}else{

			obj.Text.innerHTML = obj.innerText2;
			obj.Text.style.color = "#333";
		}
	}
}